package com.ruijie.autotest.log.validation.common;

import com.minelx.landisk.filesystem.Paths;
import com.minelx.landisk.filesystem.core.Directory;
import com.minelx.landisk.filesystem.core.File;
import com.ruijie.autotest.log.common.crypto.CBC;
import com.ruijie.autotest.log.common.crypto.DESAlgorithm;
import com.ruijie.autotest.log.common.crypto.ICryptoFactory;
import com.ruijie.autotest.log.common.crypto.Padding;

import java.util.List;

import static com.minelx.landisk.filesystem.core.File.byExtension;

public class ExtractionOfDecryptedMainTest {

	private static final String PASSWORD = "12345678";

	private static final String IV_PASSWORD = "12345678";

	public static void main(String[] args) throws Exception {
		Directory rootDirectory = Paths.root("/D:/FTP/派博ftp/");

		List<File> zipFiles = rootDirectory.childrenFiles()
				.filter(which -> !which.getName().startsWith("decrypted_")) // not starts with "decrypted_"
				.filter(byExtension("zip")).all();

		List<File> files = ICryptoFactory.decryptedFiles(zipFiles,
				CBC.create(new DESAlgorithm(), PASSWORD, IV_PASSWORD, Padding.NO_PADDING).cryptoFactory().decryption());
		System.out.println("files = " + files);
		System.out.println("decryption is done.");
	}
}
